package cn.net.xinyi.xs.dao.hr;

import java.util.List;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import cn.net.xinyi.xs.dao.Dao;
import cn.net.xinyi.xs.model.hr.User;

/**
 * User Data Access Object (GenericDao) interface.
 * 
 * @author <a href="mailto:caihualin2009@gmail.com">Cai Hua</a>
 */
public interface UserDao extends Dao {

	User get(Long userId);

	/**
	 * Gets users information based on login name.
	 * 
	 * @param username
	 *            the user's username
	 * @return user populated user object
	 */
	@Transactional
	User getUserByUserName(String userName);

	/**
	 * Gets a list of users ordered by the uppercase version of their username.
	 * 
	 * @return List populated list of users
	 */
	List<User> getUsers();

	/**
	 * Saves a user's information.
	 * 
	 * @param user
	 *            the object to be saved
	 * @return the persisted User object
	 */
	User saveUser(User user);

	/**
	 * Retrieves the password in DB for a user
	 * 
	 * @param username
	 *            the user's username
	 * @return the password in DB, if the user is already persisted
	 */
	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	String getUserPassword(String username);
}
